<?php

namespace app\api\model;

use think\Cache;
use think\Model;

class Admin extends Model
{

    //自动写入时间
    protected $autoWriteTimestamp = true;

    /**
     * 时间格式化
     * @var string
     */
    protected $dateFormat = 'Y-m-d H:i:s';

    protected $type = [
        'logintime' => 'timestamp'
    ];
    /**
     * 隐藏某些字段展示
     * @var array
     */
    protected $hidden = [
        'password',
        'salt',
    ];

    private static $adminListKey = 'ADMIN_LIST_KYE:';

    /**
     * 获取所有管理员列表
     */
    public function getAdminAll()
    {

        $adminList = Cache::store('redis')->get(self::$adminListKey);
        if (!$adminList) {
//            $where['is_del'] = SysConfig::DEFAULT_ZERO;
            $where['is_del'] = 0;
            $adminList = self
                ::field('id,username')
                ->where($where)
                ->select()
                ->toArray();
            if ($adminList) {
                $adminList = Cache::store('redis')->set(self::$adminListKey, $adminList, 86400);
            }
        }
        return $adminList;

    }


}